home *** CD-ROM | disk | FTP | other *** search
- Path: rap.SanDiegoCA.ATTGIS.COM!es013!jbc
- From: jbc@ElSegundoCA.ATTGIS.COM (Jim Chapman)
- Newsgroups: comp.lang.c++
- Subject: Re: Using multiple functions in one file
- Date: 13 Jan 1996 01:04:28 GMT
- Organization: AT&T Global Information Solutions
- Distribution: world
- Message-ID: <4d70es$gig@rap.SanDiegoCA.ATTGIS.COM>
- Reply-To: jbc@ElSegundoCA.ATTGIS.COM
- NNTP-Posting-Host: es013.elsegundoca.attgis.com
-
- In article 31EA@sierra.net, T Colwell <snowbull@sierra.net> () writes:
- > Andrew Belo wrote:
- > >
- > > I have written an example program out of a book and it keeps giving me an
- > > error that says "Call to undefined function 'butler' in function main()"
- > > I am using Borland C++ for Dos, Win and Win 32 Version 4.5.
- > >
- > > The book is called C: Step by Step, and the program is as follows.
- > >
- > > /* two_func.c -- a program using two functions in one file */
- > > #include <stdio.h>
- > > main()
- > > {
- > > printf("I will summon the butler function. \n");
- > > butler();
- > > printf("Yes. Bring me some tea and floppy disks.\n");
- > > }
- > > butler()
- > > {
- > > printf("You rang, sir? \n");
- > > }
- > >
- > ------
- > Try placing butler() before main() and recompiling.
-
-
- That would work, but it might be helpful to explain that this is a perfectly
- legal C program; it just doesn't happen to be legal C++. C allows a
- function to be called before (lexically speaking) it is defined. The
- function is then considered implicitly declared as returning int. C++
- requires that the function declaration appear before the function call.
-
- ---
- ==== AT&T | Jim Chapman |
- =--=== Global | Multimedia Projects | jbc@ElSegundoCA.ATTGIS.COM
- =--=== Information | 100 N. Sepulveda Blvd. | Voice: (310) 524-6747
- ==== Solutions | El Segundo, CA 90245 | FAX: (310) 524-5515
-
-